﻿Imports System.Xml
Imports System.IO

Public Class ucDrogas

    Private ds As New DataSet


    Public Property getDrogas As String
        Get
            Return cmbDroga.Text
        End Get
        Set(value As String)
            cmbDroga.Text = value
        End Set
    End Property

    Public Property getIndiceDroga As Integer
        Get
            Return cmbDroga.SelectedIndex
        End Get
        Set(value As Integer)
            cmbDroga.SelectedIndex = value
        End Set
    End Property

    Public Property getResultado As String
        Get
            Return cmbDroga.SelectedValue
        End Get
        Set(value As String)
            cmbDroga.SelectedValue = value
        End Set
    End Property

    Private Sub carregaUcDrogas()
        Try
            Dim caminho As String = Application.StartupPath & "\xml\drogas.xml"
            If Not File.Exists(caminho) Then
                MsgBox("O arquivo drogas.xml não foi gravado para o diretório \ambiente geralaudos\xml")
            Else
                ds.ReadXml(caminho)
           
            End If

        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub

    Private Sub ucDrogas_Load(sender As Object, e As EventArgs) Handles Me.Load

        carregaUcDrogas()

        With Me.cmbDroga
            .DisplayMember = "DESCRICAO"
            .ValueMember = "RESULTADO"
            .DataSource = ds.Tables("DROGA")
            cmbDroga.SelectedValue = 0
        End With
    End Sub
    Public Event onSelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

    Private Sub cmbDroga_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmbDroga.SelectedIndexChanged
        RaiseEvent onSelectedIndexChanged(sender, e)
    End Sub

End Class
